// Created by WXX on 2021/10/22 19:56
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    bool canJump(vector<int>& nums) {

        for (int i = 0, j = 0; i < nums.size(); i++) {
            if (j < i) return false;
            j = max(j, nums[i] + i);
        }
        return true;
    }
};

int main() {

    vector<int> nums = {2, 3, 1, 1, 4};
    cout << Solution().canJump(nums) << endl;  // true

    return 0;
}
